package xyz.hubery.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.hubery.mapper.StockRecordMapper;
import xyz.hubery.model.Constants;
import xyz.hubery.pojo.StockRecord;

@Slf4j
@Service
@RocketMQMessageListener(
        topic = Constants.SYNC_STOCK_OPERATION_TOPIC,
        consumerGroup = "sync_stock_operation_group"
)
public class StockRecordLinstener implements RocketMQListener<StockRecord> {

    @Autowired
    private StockRecordMapper stockRecordMapper;

    @Override
    public void onMessage(StockRecord stockRecord) {
        stockRecordMapper.insert(stockRecord);
    }

}
